import AnalysisUtils, {EVENT_QOE} from "./AnalysisUtils";

export default class EventSchedule {

    bean;

    constructor(bean) {
        this.bean = bean;
    }

    audioTotalBlockTime;
    lastReportAudioTotalBlockTime;
    videoTotalBlockTime;
    lastReportVideoTotalBlockTime

    interval;

    startSchedule() {
        if (!this.interval) {
            this.interval = setInterval(() => {
                // this.bean.totalVideoDuration = 10;
                // this.bean.totalAudioDuration = 10;

                // this.bean.audioCatonDuration = this.audioTotalBlockTime - this.lastReportAudioTotalBlockTime;
                // this.bean.totalVideoCatonDuration = this.videoTotalBlockTime - this.lastReportVideoTotalBlockTime;

                // this.bean.videoCatonRate = this.bean.totalVideoCatonDuration / 10.0;
                // this.bean.audioCatonRate = this.bean.audioCatonDuration / 10.0;

                // this.lastReportVideoTotalBlockTime = this.videoTotalBlockTime;
                // this.lastReportAudioTotalBlockTime = this.audioTotalBlockTime;

                AnalysisUtils.putEvent({eventName: EVENT_QOE, bean: this.bean});
            }, 10000)
        }
    }

    stopSchedule() {
        clearInterval(this.interval)
        this.interval = undefined;
    }

}
